    package arithmetic;

    import java.util.ArrayList;

    public class A01 {
        /**
         * 有四个数字：1、2、3、4，能组成多少个互不相同且无重复数字的三位数？各是多少？
         */

        public static void main(String[] args) {
            ArrayList<Integer> arrayList = new ArrayList<Integer>();
            arrayList.add(1);
            arrayList.add(2);
            arrayList.add(3);
            arrayList.add(4);
            demo(arrayList);
        }
        public static void demo(ArrayList<Integer> arrayList){
            ArrayList<Integer> arrayList1 = new ArrayList<>();
            for (int i = 0; i < arrayList.size(); i++) {
                ArrayList<Integer> arr = (ArrayList<Integer>) arrayList.clone();
                String str = String.valueOf(arrayList.get(i));
                arr.remove(arrayList.get(i));
                for (int j = 0; j < arr.size(); j++) {
                    String str1 =str+arr.get(j);
                    ArrayList<Integer> arr2 = (ArrayList<Integer>) arr.clone();
                    arr2.remove(arr2.get(j));
                    for (int k = 0; k < arr2.size(); k++) {
                        arrayList1.add(Integer.valueOf(str1+arr2.get(k)));
                    }
                }
            }
            //输出结果
            for (int i = 0; i < arrayList1.size(); i++) {
                System.out.println(arrayList1.get(i));
            }
        }
    }
